package com.lyf.scm.job.remote.facade;

import cn.hutool.core.date.DateUtil;
import com.lyf.scm.common.enums.ResponseMsg;
import com.lyf.scm.job.remote.DirectlyStoreRemoteService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * description:
 *直营（门店）预测计划Job
 * @author: haodong
 * @data: 2020/9/3 10:17
 */
@Slf4j
@Component
public class DirectlyStoreFacade {

    @Resource
    private DirectlyStoreRemoteService directlyStoreService;

    public void updateConfirmTarget() {
        Date startDate = DateUtil.beginOfWeek(new Date());
        Date endDate = DateUtil.beginOfDay(DateUtil.endOfWeek(DateUtil.offsetWeek(startDate,1)));
        Response response = directlyStoreService.updateConfirmTarget(DateUtil.formatDate(startDate),DateUtil.formatDate(endDate));
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
    }
}
